<template>
	<view class="promote-visitor" :style="{'--height':`${topNavbarBgHeight}rpx`}">
		<common-navbar title="好友助力" :background="{'background':'#2889F0'}" titleColor="#ffffff" backIconColor="#ffffff" :customBack="customBack">
		</common-navbar>
		<friendList @showPopup="showPopup"/>
		<promotePopup ref="promotePopup"/>
	</view>
</template>

<script>
	import friendList from "./components/friend_list/friendList.vue";
	import promotePopup from "./components/promote_popup/promotePopup.vue";
	export default {
		components: {
			friendList,
			promotePopup
		},
		data() {
			return {
				// shareCode: '',
			}
		},
		onShareAppMessage(res) {
			if (res.from === 'button') { // 来自页面内分享按钮
				console.log(res.target)
			}
			return {
				title: '小律懂法邀好友送VIP,快为我助力',
				imageUrl: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-8acfaa58-aeb5-4502-8309-365d4c6cca4a/390e106a-35ef-4104-b35d-a43bf66d9c89.png',
				path: `/pages/promote_visitor/promoteVisitor?shareCode=${encodeURIComponent(this.shareCode)}`
			}
		},
		onLoad(options) {
			console.log('options>>>>>>>>>>>>>>>>>>>>>',options);
			if(options.q){
				// this.shareCode =decodeURIComponent(options.q).split('?shareCode=')[1];
				this.$u.vuex('shareCode',decodeURIComponent(options.q).split('?shareCode=')[1]);
			}else if(decodeURIComponent(options.shareCode)!='undefined'){
				// this.shareCode = decodeURIComponent(options.shareCode);
				this.$u.vuex('shareCode',decodeURIComponent(options.shareCode));
			}
			console.log(this.shareCode)
		},
		computed: {
			topNavbarBgHeight() {
				return 750 * (this.$systemInfo.statusBarHeight + 44) / this.$systemInfo.screenWidth;
			}
		},
		methods:{
			showPopup(){
				// this.$nextTick(()=>{
					this.$refs.promotePopup.show();
				// })
			},
			customBack(){
				uni.switchTab({
					url:'/pages/home/home'
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	@import "./promoteVisitor.scss";
</style>
